<template>
	<view class="page" :style="{minHeight:$height()}">
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="topBox">
				<view class="txt">
					结算公司：{{item.salePowerName}}
				</view>
				<view class="look" @click="$next(`/pages/commissionCenters/commissionDetail?importId=${item.id}`)">
					查看明细
				</view>
			</view>
			<view class="buttomBox">
				<view class="tateBox">
					<view class="tateTxt" style="margin-right: 20rpx;">
						结算日期:
					</view>
					<view class="tate">
						{{item.importDate}}
					</view>
				</view>
				<view class="dowload" v-if="item.confirmed == 0" @click="confirm(item.id)">
					确认佣金
				</view>
				<view class="dowload" v-else>
					已确认
				</view>
			</view>
		</view>
		<!-- 加载更多 -->
		<u-loadmore v-if="list.length !== 0" :status="status" :load-text="loadText" />
		<image v-else src="@/static/image/empty.png" mode="widthFix" class="is-empty"></image>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				loadText: {
					loadmore: '轻轻上拉，加载更多',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				more: false,
				page: 1, //页码
				limit: 10, //条数
			}
		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.getConfirmAccountsRes()
		},
		//上拉加载
		onReachBottom() {
			if (this.page == 1) {
				return
			}
			if (this.more) {

				this.getConfirmAccountsRes()
			}
		},
		onLoad() {
			this.getConfirmAccountsRes()
		},
		methods: {
			getConfirmAccountsRes() {
				this.$axios.request(this.$api.getConfirmAccountsRes, "GET", {
					page: this.page,
					limit: this.limit,
					orderField: 'id',
					order: 'desc'
				}).then((val) => {
					uni.stopPullDownRefresh();
					this.list = this.page == 1 ? val.data.list : this.list.concat(val.data.list)
					if (Math.ceil(val.data.total / this.limit) > this.page) {
						this.more = true;
						this.page++
					} else {
						this.more = false;
					}
				})
			},
			confirm(id){
				this.$axios.request(this.$api.confirmAccounts,"GET",{
					importId:id
				}).then((val) => {
					this.$msg.toastCallback("确认成功",() => {
						this.getConfirmAccountsRes()
					})
				})
			},
		}
	}
</script>

<style>
	.page {
		width: 100%;
		background-color: #F0F2F5;
	}

	.item {
		display: flex;
		justify-content: space-between;
		flex-direction: column;
		width: 100%;
		height: 148rpx;
		background-color: #FFFFFF;
		padding: 16rpx 35rpx;
		margin-top: 16rpx;
	}

	.topBox,
	.buttomBox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
	}

	.txt {
		height: 50rpx;
		font-size: 36rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 50rpx;
		color: #333333;
		opacity: 1;
	}

	.look {
		height: 50rpx;
		background-color: #2E6ADF;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 300;
		line-height: 50rpx;
		padding: 0 26rpx;
		color: #FFFFFF;
	}

	.dowload {
		height: 50rpx;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 300;
		line-height: 50rpx;
		padding: 0 26rpx;
		color: #2E6ADF;
		background-color: #FFFFFF;
		border: 1rpx solid #2E6ADF;
		border-radius: 4rpx;
	}

	.tateBox {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		height: 100%;
		font-size: 36rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		color: #222222;
		opacity: 1;
	}

	.more {
		font-size: 24rpx;
		font-family: "PingFang SC";
		text-align: center;
		font-weight: 300;
		color: #BBBBBB;
		opacity: 1;
		margin: 24rpx auto 116rpx;
	}
</style>